package es.udc.emarketapp.emarket.model.shippingFacade.actions;

import java.sql.Connection;

import es.udc.emarketapp.emarket.model.orderDetails.dao.SQLOrderDetailsDAO;
import es.udc.emarketapp.emarket.model.orderDetails.dao.SQLOrderDetailsDAOFactory;
import es.udc.emarketapp.emarket.model.orderDetails.vo.OrderDetailsVO;
import es.udc.emarketapp.emarket.model.shipping.dao.SQLShippingDAO;
import es.udc.emarketapp.emarket.model.shipping.dao.SQLShippingDAOFactory;
import es.udc.fbellas.j2ee.util.exceptions.InstanceNotFoundException;
import es.udc.fbellas.j2ee.util.exceptions.InternalErrorException;
import es.udc.fbellas.j2ee.util.exceptions.ModelException;
import es.udc.fbellas.j2ee.util.sql.NonTransactionalPlainAction;


public class CalculateShippingCostsAction implements NonTransactionalPlainAction {

    private String idSeller;
    private String country;
    private Double weight;
    
    public CalculateShippingCostsAction(String idSeller, String country,
            Double weight) {
        this.idSeller = idSeller;
        this.country = country;
        this.weight = weight;
    }
    
    public Object execute(Connection connection) 
        throws InternalErrorException, ModelException {

         SQLShippingDAO shippingDAO = SQLShippingDAOFactory.getDAO();

         Double price = shippingDAO.findCost(connection, idSeller, country,
                  weight);

        return price;

    }


}

